<%@page import="com.nescafe.nescafepromo.model.GaisanoBranch"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div>


	<div style="float: left; width: 100%; margin: auto; clear: right;">
		<h1 class="content-title">Input Purchases</h1>
		<br /> <br /> <br />

		<div id="register-form-dialog" style="float: left;">
			<form id="register-form">
				<table>
					<tr>
						<th>Receipt No:</th>
						<td><input type="text" name="receipt_no" id="reg-receipt-no" /></td>
					</tr>

					<tr>
						<th>Amount:</th>
						<td><input type="text" name="amount" id="reg-amount" /></td>
					</tr>

					<tr>
						<th>Receipt Date:</th>
						<td><input id="reg-receipt-time" type="text" class="date-field" /></td>
					</tr>

					<tr>
						<th>Email:</th>
						<td><input type="text" name="email" id="reg-email" /></td>
					</tr>

					<tr>
						<th>Branch:</th>
						<td><select name='branch'>
								<%for (GaisanoBranch b: GaisanoBranch.values()){%>
								<option value='<%=b.getCode()%>'><%=b.getName()%></option>
								<%}%>
						</select></td>
					</tr>

				</table>
				<br /> <br /> <input type="hidden" name="receipt_time" id="formatted-rt" /> <input type="hidden" name="com" value="ADD_PURCAHSE" />
			</form>
			<button id="btnAdd">Add purchase</button>
		</div>
	</div>



	<script type="text/javascript">
		$(function() {
			$("#btnAdd").button().click(function() {
				var d = $('#reg-receipt-time').datepicker('getDate');
				$('#formatted-rt').val($.datepicker.formatDate('yymmdd', d));
				var params = $('#register-form').serialize();
				$.post("../admin_gateway", params, function(responseData) {
					$('#register-form input').val('');
					alert(responseData);
				});
			});

			$(".date-field").datepicker({
				dateFormat : 'M d, yy'
			}).datepicker('setDate', new Date());
		});
		
	</script>
</div>